{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import k3d\n",
    "\n",
    "model_matrix = [\n",
    "     3.5, -2.5, 2.5, 0.0,\n",
    "     0.0,  3.5, 3.5, 0.0,\n",
    "    -3.5, -2.5, 2.5, 0.0,\n",
    "     0.0,  0.0, 0.0, 1.0\n",
    "]\n",
    "stl = \"\"\"solid\n",
    "    facet normal 0 0 0\n",
    "        outer loop\n",
    "            vertex -1.000000 1.000000 -1.000000\n",
    "            vertex -1.000000 -1.000000 -1.000000\n",
    "            vertex -1.000000 -1.000000 1.000000\n",
    "        endloop\n",
    "    endfacet\n",
    "    facet normal 0 0 0\n",
    "        outer loop\n",
    "            vertex -1.000000 -1.000000 1.000000\n",
    "            vertex -1.000000 1.000000 1.000000\n",
    "            vertex -1.000000 1.000000 -1.000000\n",
    "        endloop\n",
    "    endfacet\n",
    "    facet normal 0 0 0\n",
    "        outer loop\n",
    "            vertex 1.000000 -1.000000 1.000000\n",
    "            vertex 1.000000 1.000000 1.000000\n",
    "            vertex -1.000000 1.000000 1.000000\n",
    "        endloop\n",
    "    endfacet\n",
    "    facet normal 0 0 0\n",
    "        outer loop\n",
    "            vertex -1.000000 1.000000 1.000000\n",
    "            vertex -1.000000 -1.000000 1.000000\n",
    "            vertex 1.000000 -1.000000 1.000000\n",
    "        endloop\n",
    "    endfacet\n",
    "endsolid\"\"\"\n",
    "\n",
    "plot = k3d.plot()\n",
    "plot += k3d.stl(stl, color=0xFF0000, model_matrix=model_matrix)\n",
    "plot.display()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_matrix = [\n",
    "    7.0, -5.0,  5.0, -15.0,\n",
    "    0.0, -7.0, -7.0,   0.0,\n",
    "    7.0,  5.0, -5.0,   0.0,\n",
    "    0.0,  0.0,  0.0,   1.0\n",
    "]\n",
    "\n",
    "plot += k3d.stl(open('assets/stl.stl').read(), model_matrix=model_matrix)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.objects[0].wireframe = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.objects[1].wireframe = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from k3d.helpers import download\n",
    "filename = download('https://upload.wikimedia.org/wikipedia/commons/a/af/Asad_Al-Lat.stl')\n",
    "plot += k3d.stl(open(filename, 'rb').read())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.objects[2].flat_shading = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
